package com.neusoft.neu.fy25g01.n98.service.impl;

import com.neusoft.neu.fy25g01.n98.entity.CommonResult;
import com.neusoft.neu.fy25g01.n98.entity.Person;
import com.neusoft.neu.fy25g01.n98.entity.ResultCode;
import com.neusoft.neu.fy25g01.n98.mapper.PersonMapper;
import com.neusoft.neu.fy25g01.n98.service.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PersonServiceImpl implements PersonService {
    @Autowired
    private PersonMapper personMapper;

    @Override
    public CommonResult<List<Person>> findAll() {
        List<Person> list = personMapper.findAll(); // personMapper.selectList(null);
        if (list != null && list.size() != 0) {
            return CommonResult.success(list);
        } else return CommonResult.failed();

    }

    @Override
    public CommonResult modPerson(Person person) {
        int i = personMapper.updateById(person);
        if (i > 0)
            return CommonResult.success();
        else
            return CommonResult.failed(ResultCode.FAIL);

    }
}
